﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Drawing;
using System.Configuration;


namespace TodoSuspensionWeb
{
    public partial class contacto : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        

        

        protected void Button7_Click(object sender, EventArgs e)
        {
            try
            {
                //MailMessage correo = new MailMessage();
                //correo.From = new MailAddress(txtNombre.Text + "<" + txtEmail.Text + ">");
                //correo.To.Add(new MailAddress("favio-pincirolli@hotmail.com"));
                //correo.Subject ="WEB";
                //correo.Body = txtMensaje.Text +"  Télefono de Contacto : " + txtTelefono.Text;
                //SmtpClient client = new SmtpClient();
                
                //client.EnableSsl = true;

                //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object s,
                //System.Security.Cryptography.X509Certificates.X509Certificate certificate,
                //System.Security.Cryptography.X509Certificates.X509Chain chain,
                //System.Net.Security.SslPolicyErrors sslPolicyErrors)
                //{
                //    return true;
                //};

                //client.Send(correo);
                //lblMensajeError.Text = " Mensaje enviado correctamente";
                //lblMensajeError.ForeColor = Color.Green;

                //txtNombre.Text = "";
                //txtEmail.Text = "";
                //txtTelefono.Text = "";
                //txtMensaje.Text = "";


                MailMessage EmailMsg = new MailMessage();
                EmailMsg.From = new MailAddress(txtEmail.Text.ToString());
                EmailMsg.To.Add(new MailAddress("favio-pincirolli@hotmail.com"));
                EmailMsg.Subject=("test email form");
                EmailMsg.Sender = EmailMsg.From;
                EmailMsg.Body = "<html><body>this is de test<hr>TEST TEST</body></html>";
                EmailMsg.IsBodyHtml=true;
                EmailMsg.Priority=MailPriority.Normal;
                SmtpClient MailClient=new SmtpClient("smtp.hotmail.com");
                MailClient.EnableSsl = true;
                MailClient.Credentials = new System.Net.NetworkCredential("favio-pincirolli@hotmail.com", "curriculumvitae");
                MailClient.Send(EmailMsg);

            }
            catch (Exception ex)
            {
                lblMensajeError.Text = "Error al enviar, favor contacte al administrador admin@dominio.com ";
                lblMensajeError.ForeColor = Color.Red;
            }
            finally
            {

            }
        }
    }
}